
package com.hua.service.impl;

import com.hua.mapper.TempMapper;
import com.hua.pojo.Temp;
import com.hua.service.TempService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hua
 * @since 2023-12-24
 */
@Service
public class TempServiceImpl extends ServiceImpl<TempMapper, Temp> implements TempService {

    @Autowired
    private TempMapper tempMapper;

    //获取首页banner展示图API
    @Override
    public Map<String, Object> getCarouselUrlList() {

        //执行查询所有的页面轮播图的url信息
        List<Temp> pirUrlList = this.baseMapper.selectList(null);
        //把数据封装到map集合，data返回数据
        Map<String, Object> data = new HashMap<>();
        data.put("data",pirUrlList);

        return data;
    }

    //覆盖的第一步①全部删除
    @Override
    public int deleteAll() {
        return tempMapper.deleteAll();
    }

    //覆盖的第二部②插入
    @Override
    public int insertOne(Temp temp) {
        return this.baseMapper.insert(temp);
    }

    //新增banner图
    @Override
    public int addBannerImg(Temp temp) {
        return this.baseMapper.insert(temp);
    }


    //删除banner图,通过id删除
    @Override
    public int deleteBannerImg(Temp deleteTemp) {
        int i = this.baseMapper.deleteById(deleteTemp);
        return i;
    }
}
